/* $RCSFile: ADNDynActivity.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynActivity.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynActivity : ADNDynActivityBase
	{

        public override bool HasOwnerProperty
        {
            get{   return true;}
        }

        public override bool HasOwningBusinessUnitProperty
        {
            get{   return true;}
        }

        /// <summary>
		/// Reserved for template methods: do not use directly
		/// </summary>
        public ADNDynActivity(): base()
		{}

        public ADNDynActivity(CRMWrapperBase w,string subj,string schemaNm)
			: base(w, subj,schemaNm)
		{}

        public ADNDynActivity(CRMWrapperBase w,string schemaNm, Guid CrmId)
			: base(w,schemaNm, CrmId)
		{}

		public ADNDynActivity(CRMWrapperBase w,string entName,InternalDynamicEntity e)
			: base(w,entName,e,null,null)
		{}

		public ADNDynActivity(CRMWrapperBase w,string entName,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(w,entName,e,prop,s)
		{}

        public ADNDynActivity(ResetWrapperHandler fn,string subj,string schemaNm)
			: base(fn, subj,schemaNm)
		{}

        public ADNDynActivity(ResetWrapperHandler fn,string schemaNm, Guid CrmId)
			: base(fn,schemaNm, CrmId)
		{}

		public ADNDynActivity(ResetWrapperHandler fn,string entName,InternalDynamicEntity e)
			: base(fn,entName,e,null,null)
		{}

		public ADNDynActivity(ResetWrapperHandler fn,string entName,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(fn,entName,e,prop,s)
		{}

        /// <summary>
        /// Gets or sets the category of the activity. 
        /// </summary>
        [CrmDynAttribute(CrmStr.email), CrmDynAttribute(CrmStr.appointment), CrmDynAttribute(CrmStr.phonecall),CrmDynAttribute(CrmStr.task),CrmDynAttribute(CrmStr.fax),CrmDynAttribute(CrmStr.letter)]
        public string category
        {
            get
            {
                return StringPropertyValue(CrmStr.category);
            }
            set
            {
                AddStringProperty(CrmStr.category,value);
            }
        }

        /// <summary>
        /// Gets or sets the subcategory of the activity. 
        /// </summary>
        [CrmDynAttribute(CrmStr.email), CrmDynAttribute(CrmStr.appointment), CrmDynAttribute(CrmStr.phonecall),CrmDynAttribute(CrmStr.task),CrmDynAttribute(CrmStr.fax),CrmDynAttribute(CrmStr.letter)]
        public string subcategory
        {
            get
            {
                return StringPropertyValue(CrmStr.subcategory);
            }
            set
            {
                AddStringProperty(CrmStr.subcategory,value);
            }
        }

        /// <summary>
        /// virtual because on 'detail' records it is only a uniqueidentifier property
        /// </summary>
        [CrmDynAttribute(CrmStr.email), CrmDynAttribute(CrmStr.appointment), CrmDynAttribute(CrmStr.phonecall),CrmDynAttribute(CrmStr.task),CrmDynAttribute(CrmStr.fax),CrmDynAttribute(CrmStr.letter),CrmDynAttribute(CrmStr.campaignactivity)]
        public Guid owningbusinessunit
        {
            get
            {
                return LookupPropertyValue(CrmStr.owningbusinessunit);
            }
            set
            {
                AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value);
            }
        }

        public string owningbusinessunitName
        {
            get
            {
                return LookupPropertyName(CrmStr.owningbusinessunit);
            }
        }

        #region utilities

        public List<DynEntity> ExtractPartyList(string PartyListName,bool retrieve,bool isAdmin)
        {
            if ( ContainsKey(PartyListName) )
                return wrapper.Util.ExtractFromActivityParty(DynamicEntityArrayProperty(PartyListName),retrieve,isAdmin);
            return null;
        }

        public void Route(ADNDynQueue dynQ,RouteType type,bool isAdmin)
        {
            wrapper.Util.Route(this,dynQ,type,isAdmin);
        }
        #endregion utilities
    }
}
